#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fts.h>
#include <string.h>

//用来进行取模校验,根据实际文件大小来取的模数
#define  JSONSIZE   1400
#define  INSTSIZE   108000000
int main( int argc, char **argv )
{
    char * str_user = "./user00001";
    char * str_down = "AisEsmAgentSetup.exe";

    FTSENT *ftsent;
    char * const path[2] = {"./", NULL};
    FTS *fts = fts_open(path, FTS_LOGICAL, NULL);
    if ( !fts )
        return -1;

    while ( (ftsent = fts_read(fts)) )  
    {
        if( 0 == memcmp( str_user, ftsent->fts_accpath, 4) )
        {
            struct stat *stat = ftsent->fts_statp;
            //printf("ret %d ###%s###%s\n", memcmp( str_user, ftsent->fts_accpath, 4), str_user, ftsent->fts_accpath);
            if ( S_ISREG(stat->st_mode) )
            {   
                if( 1 == (stat->st_size / JSONSIZE) || 1 == (stat->st_size / INSTSIZE) )  //取模校验正常
                {
                    printf("[infor] %s is normal file,%dbytes size, check file ok!\n", ftsent->fts_accpath, stat->st_size);
                }  
                else
                {
                    printf("[error] %s is normal file,%dbytes size, check file error!\n", ftsent->fts_accpath, stat->st_size);
                }    
            }
        }

    }
     
    fts_close( fts );
    return 0;
}